package com.hejing.Collection子接口Set;

import org.junit.Test;

import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * ClassName: SetTest
 * Package: com.hejing.Collection子接口Set
 * Description:
 *
 * @Author: HeJing
 * @Create: 2023-05-18 11:26
 * @Version: 1.0
 */
public class SetTest {

    @Test
    public void test01(){

        Set set = new LinkedHashSet();

        set.add("AA");
        set.add("BB");
        set.add(123);
        set.add(true);
        set.add(new Person("luffy", 19));

        Iterator iterator = set.iterator();

        while(iterator.hasNext()) {
            System.out.println(iterator.next());
        }

        System.out.println("*************");
        System.out.println(set.contains(new Person("luffy", 19)));
    }

    @Test
    public void test02(){

        Set set = new HashSet();

        set.add("AA");
        set.add("BB");
        set.add(123);
        set.add(true);
        set.add(new Person("luffy", 19));

        Iterator iterator = set.iterator();

        while(iterator.hasNext()) {
            System.out.println(iterator.next());
        }

        System.out.println("*************");
        System.out.println(set.contains(new Person("luffy", 19)));
    }
}

















